package com.beten.util;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileWriter {
	private static final String TAG = "FileWriter";
	boolean isOpen=false;
	BufferedOutputStream out;
	public void open(String fileName)
	{
		try {
			out = new BufferedOutputStream(new FileOutputStream(fileName));
		} catch (FileNotFoundException e) {
			DebugHelp.LogD(TAG, e.toString());
			return;
		}  
		isOpen=true;
	}
	public boolean IsOpen()
	{
		return isOpen;
	}
	public void writeData(byte[] data)
	{
		if(!isOpen)
			return;
		  try {
			out.write(data);
		} catch (IOException e) {
			DebugHelp.LogD(TAG, e.toString());
		}
	}
	public void close()
	{
		if(!isOpen)
			return;
		 try {
				out.close();
			} catch (IOException e) {
				DebugHelp.LogD(TAG, e.toString());
			}
		
	}
}
